<?php
/**
 * Custom Post Types Registration
 * 
 * @param array $custom_post_type
 * 
 * @author Sam
 * @since Urban Meandering 1.0
 */
function um_register_custom_post_type( $custom_post_type )
{
  register_post_type( 
        $custom_post_type['post_type'],
        array(
              'labels' => array(
                    'name' => __( $custom_post_type['name'] ),
                    'singular_name' => __( $custom_post_type['singular_name'] ),
                    'add_new' => _x( 'Add New', $custom_post_type['add_new'] ),
                    'add_new_item' => __( $custom_post_type['add_new_item'] ),
                    'edit_item' => __( $custom_post_type['edit_item'] ),
                    'new_item' => __( $custom_post_type['new_item'] ),
                    'view_item' => __( $custom_post_type['view_item'] ),
                    'search_items' => __( $custom_post_type['search_items'] ),
                    'not_found' => __( $custom_post_type['not_found'] ),
                    'not_found_in_trash' => __( $custom_post_type['not_found_in_trash'] )
              ),
              'public' => $custom_post_type['public'],
							'publicly_queryable' => $custom_post_type['publicly_queryable'],
							'exclude_from_search' => $custom_post_type['exclude_from_search'],
              'has_archive' => $custom_post_type['has_archive'],
              'hierarchical' => $custom_post_type['hierarchical'],
              'rewrite' => $custom_post_type['rewrite'],
							'query_var' => $custom_post_type['query_var'],
							'show_ui' => $custom_post_type['show_ui'],
							'show_in_nav_menus' => $custom_post_type['show_in_nav_menus'],
              'supports'=> $custom_post_type['supports'],
              'menu_position' => $custom_post_type['menu_position'],
              'taxonomies' => $custom_post_type['taxonomies']
        )
  );
}

/*
'supports'=> array(
      'title',
      'editor',
      'author',
      'thumbnail', 
      'excerpt',
      'trackbacks',
      'custom-fields',
      'comments',
      'revisions',
      'post-formats',
      'page-attributes'
),
*/


/**
 * Custom Post Types Definition
 * 
 * @author Sam
 * @since Urban Meandering 1.0
 */
function um_define_custom_post_types()
{
  $post_types = array(
        'food' => array(
              'post_type' => 'food',
              'name' => 'Food',
              'singular_name' => 'Food',
							'has_archive' => true,
							'query_var' => true,
              'slug' => 'food',
							'public' => true,
							'publicly_queryable' => true,
							'exclude_from_search' => false,
							'rewrite' => array ( 
										'slug' => 'food'
							),
							'show_ui' => true,
							'show_in_nav_menus' => true,
              'add_new' => 'Add new',
              'add_new_item' => 'Add new Food',
              'edit_item' => 'Edit Food',
              'new_item' => 'New Food',
              'view_item' => 'View Food',
              'search_items' => 'Search Food',
              'not_found' => 'No Foods found',
              'not_found_in_trash' => 'No Foods found in trash',
              'menu_position' => 5, 
              'hierarchical' => false,
              'supports' => array( 
                    'title',
                    'editor',
                    'author',
                    'thumbnail', 
                    'excerpt',
                    'trackbacks',
                    //'custom-fields',
                    'comments',
                    'revisions'
              ),
							'taxonomies' => array(
										'category',
										'post_tag'
							)
        ),
//        'event' => array(
//              'post_type' => 'event',
//              'name' => 'Events',
//              'singular_name' => 'Event',
//							'has_archive' => true,
//							'query_var' => true,
//              'slug' => 'event',
//							'public' => true,
//							'publicly_queryable' => true,
//							'exclude_from_search' => false,
//							'rewrite' => array(
//										'slug' => 'event'
//							),
//							'show_ui' => true,
//							'show_in_nav_menus' => true,
//              'add_new' => 'Add new',
//              'add_new_item' => 'Add new Event',
//              'edit_item' => 'Edit Event',
//              'new_item' => 'New Event',
//              'view_item' => 'View Event',
//              'search_items' => 'Search Event',
//              'not_found' => 'No Events found',
//              'not_found_in_trash' => 'No Events found in trash',
//              'menu_position' => 5,
//              'hierarchical' => false,
//              'supports' => array( 
//                    'title',
//										'revisions',
//										'page-attributes',
//										'thumbnail',
//										'editor',
//										'author',
//                    'excerpt',
//                    'trackbacks',
//                    //'custom-fields',
//                    'comments'
//              ),
//							'taxonomies' => array(
//										'category',
//										'post_tag'
//							)
//        ),
        'travels-activities' => array(
              'post_type' => 'travel-activity',
              'name' => 'Travels and Activities',
              'singular_name' => 'Travel and Activity',
							'has_archive' => true,
							'query_var' => true,
              'slug' => 'travel-activity',
							'public' => true,
							'publicly_queryable' => true,
							'exclude_from_search' => false,
							'rewrite' => array(
								'slug' => 'travel-activity'
							),
							'show_ui' => true,
							'show_in_nav_menus' => true,
              'add_new' => 'Add new',
              'add_new_item' => 'Add new Travel and Activity',
              'edit_item' => 'Edit Travel and Activity',
              'new_item' => 'New Travel and Activity',
              'view_item' => 'View Travel and Activity',
              'search_items' => 'Search Travel and Activity',
              'not_found' => 'No Travel and Activity found',
              'not_found_in_trash' => 'No Travel and Activity found in trash',
              'menu_position' => 5,
              'hierarchical' => false,
              'supports' => array( 
                    'title',
										'revisions',
										'page-attributes',
										'thumbnail',
										'editor',
										'author', 
                    'excerpt',
                    'trackbacks',
                    //'custom-fields',
                    'comments'
              ),
							'taxonomies' => array(
								  	'category',
										'post_tag'
							)
        ),
				'entertainment' => array(
              'post_type' => 'entertainment',
              'name' => 'Entertainment',
              'singular_name' => 'Entertainment',
							'has_archive' => true,
							'query_var' => true,
              'slug' => 'entertainment',
							'public' => true,
							'publicly_queryable' => true,
							'exclude_from_search' => false,
							'rewrite' => array(
								'slug' => 'entertainment'
							),
							'show_ui' => true,
							'show_in_nav_menus' => true,
              'add_new' => 'Add new',
              'add_new_item' => 'Add new Entertainment',
              'edit_item' => 'Edit Entertainment',
              'new_item' => 'New Entertainment',
              'view_item' => 'View Entertainment',
              'search_items' => 'Search Entertainment',
              'not_found' => 'No Entertainment found',
              'not_found_in_trash' => 'No Entertainment found in trash',
              'menu_position' => 5,
              'hierarchical' => false,
              'supports' => array( 
                    'title',
										'editor',
										'revisions',
										'author',
                    'thumbnail', 
                    'excerpt',
                    'trackbacks',
                    //'custom-fields',
                    'comments'
              ),
							'taxonomies' => array(
										'category',
										'post_tag'
							)
        ),
				'advocacies-charities' => array(
              'post_type' => 'advocacy-charity',
              'name' => 'Advocacy and Charities',
              'singular_name' => 'Advocacy and Charity',
							'has_archive' => true,
							'query_var' => true,
              'slug' => 'advocacy-charity',
							'public' => true,
							'publicly_queryable' => true,
							'exclude_from_search' => false,
							'rewrite' => array(
								'slug' => 'advocacy-charity'
							),
							'show_ui' => true,
							'show_in_nav_menus' => true,
              'add_new' => 'Add new',
              'add_new_item' => 'Add new Advocacy and Charity',
              'edit_item' => 'Edit Advocacy and Charity',
              'new_item' => 'New Advocacy and Charity',
              'view_item' => 'View Advocacy and Charity',
              'search_items' => 'Search Advocacy and Charity',
              'not_found' => 'No Advocacy and Charity found',
              'not_found_in_trash' => 'No Advocacy and Charity found in trash',
              'menu_position' => 5,
              'hierarchical' => false,
              'supports' => array( 
                    'title',
										'editor',
										'excerpt',
										'author',
										'revisions',
										'thumbnail',
                    'trackbacks',
                    //'custom-fields',
                    'comments',
              ),
							'taxonomies' => array(
										'category',
										'post_tag'
							)
        ),
				'giveaways' => array(
              'post_type' => 'giveaways',
              'name' => 'Giveaways',
              'singular_name' => 'Giveaway',
							'has_archive' => true,
							'query_var' => true,
              'slug' => 'giveaways',
							'public' => true,
							'publicly_queryable' => true,
							'exclude_from_search' => false,
							'rewrite' => array(
								'slug' => 'giveaways'
							),
							'show_ui' => true,
							'show_in_nav_menus' => true,
              'add_new' => 'Add new',
              'add_new_item' => 'Add new Giveaway',
              'edit_item' => 'Edit Giveaway',
              'new_item' => 'New Giveaway',
              'view_item' => 'View Giveaway',
              'search_items' => 'Search Giveaway',
              'not_found' => 'No Giveaway found',
              'not_found_in_trash' => 'No Giveaway found in trash',
              'menu_position' => 5,
              'hierarchical' => false,
              'supports' => array( 
                    'title',
										'editor',
										'excerpt',
										'revisions',
										'thumbnail',
										'author',
                    'trackbacks',
                    //'custom-fields',
                    'comments',
              ),
							'taxonomies' => array(
										'category',
										'post_tag'
							)
        ),
      'image-banner' => array(
              'post_type' => 'img_banner',
              'name' => 'Banners',
              'singular_name' => 'Banner',
							'has_archive' => false,
							'query_var' => true,
              'slug' => 'img-banner',
							'public' => true,
							'publicly_queryable' => true,
							'exclude_from_search' => false,
							'rewrite' => array(
								'slug' => 'img_banner'
							),
							'show_ui' => true,
							'show_in_nav_menus' => true,
              'add_new' => 'Add new',
              'add_new_item' => 'Add new Banner',
              'edit_item' => 'Edit Banner',
              'new_item' => 'New Banner',
              'view_item' => 'View Banner',
              'search_items' => 'Search Banner',
              'not_found' => 'No Banner found',
              'not_found_in_trash' => 'No Banner found in trash',
              'menu_position' => 6,
              'hierarchical' => false,
              'supports' => array( 
                    'title',
										'editor',
										'excerpt',
                    'thumbnail', 
                    'trackbacks',
                    //'custom-fields',
                
              ),
              'taxonomies' => array()
        )
  );
  
  foreach( $post_types as $post_type )
  {
    um_register_custom_post_type( $post_type );
  }
}


/**
 * Custom Taxonomies Registration
 * 
 * @param array $custom_taxonomy
 * 
 * @author Sam
 * @since Urban Meandering 1.0
 */
function um_register_custom_taxonomy( $custom_taxonomy, $custom_post_types )
{
	register_taxonomy(
				$custom_taxonomy['tax_name'],
				$custom_post_types,
				$custom_taxonomy['args']
	);
}


/**
 * Custom Taxonomies Definition
 * 
 * @author Sam
 * @since Urban Meandering 1.0
 */
function um_define_custom_taxonomies()
{
	$post_types = array(
		'food'
	);
	
	$price_group = array(
		'tax_name' => 'price-group',
		'post_type' => 'price-group',
		'args' => array(
					'hierarchical' => false,
					'label' => __('Price Group'),
					'public' => true,
					'show_ui' => true,
					'query_var' => 'price-group',
					'rewrite' => true
		)
	);
	
	um_register_custom_taxonomy( $price_group, $post_types );
}

/**
 * Initialization
 * 
 * @author Sam
 * @since Urban Meandering 1.0
 */
function um_customs_init()
{
  um_define_custom_post_types();
  um_define_custom_taxonomies();
}
add_action( 'init', 'um_customs_init', 0 );

